package com.hoaptt.pieces;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import com.hoaptt.helper.Coordinate;
import com.hoaptt.model.Board;
import java.util.ArrayList;

/**
 *
 * @author ThuHoa
 */
// Soldier
public class Soldier extends Piece {

    public Soldier(PLAYER player) {
        super(player);
        this.nameA = Character.toString((char)20853);
        this.nameB = Character.toString((char)21330);
        this.alias = Piece.NAMEPIECE.solider;
    }

    @Override
    public ArrayList<Coordinate> generateMove(Board board, Coordinate loc) {
       ArrayList<Coordinate> ar = new ArrayList<Coordinate>();
       // khi sang song vi khong the di lui nen chi co 3 kha nang di
       
       Coordinate coo = new Coordinate();
       //player A
       if (board.getAtLoc(loc).getPlayer() == Piece.PLAYER.A){
           int X[] = new int[]{0,-1, 1};
           int Y[] = new int[]{1, 0, 0};
           if (loc.getCol() <= 4) { // khi chua sang song chi co mot kha nang di len
               coo.setRow(loc.getRow());
               coo.setCol(loc.getCol() +1);
               ar.add(coo);
           } else {
             for (int i = 0; i< X.length; i++){
             Coordinate coo1 = new Coordinate(loc.getRow() + X[i], loc.getCol() + Y[i]);
                 ar.add(coo1);
             }
           }
       }
       //player B
       if (board.getAtLoc(loc).getPlayer() == Piece.PLAYER.B){
           int X[] = new int[]{-1, 0, 1};
           int Y[] = new int[]{ 0,-1, 0};
           if (loc.getCol() >= 5) { // khi chua sang song chi co mot kha nang di len
               coo.setRow(loc.getRow());
               coo.setCol(loc.getCol() -1);
               ar.add(coo);
           } else {
             for (int i = 0; i< X.length; i++){
                 Coordinate coo1 = new Coordinate(loc.getRow() + X[i], loc.getCol() + Y[i]);
                 ar.add(coo1);
             }
           }
       }


       return ar;
    }

}
